package priv.mill.inner;

import java.util.Arrays;
import java.util.Random;

public class BooksSort {

	public static void main(String[] args) {
		Book[] books=new Book[10];
		Random random = new Random(17);
		for (int i = 0; i < 10; i++) {
			books[i]=new Book(random.nextInt(100),((char)random.nextInt(130))+"java");
		}
		System.out.println(Arrays.toString(books));
		Arrays.sort(books);
		System.out.println(Arrays.toString(books));
	}
}
class Book implements Comparable{
	public Book(int nextInt, String string) {
		this.price=nextInt;
		this.name=string;
	}
	double price;
	String name;
	@Override
	public String toString() {
		return "Book [price=" + price + ", name=" + name + "]";
	}
	
	@Override
	public int compareTo(Object o) {
//		System.out.println(o instanceof Book);
		return (int) (this.price-((Book)o).price);
	}
	
}
